package com.dayouzi.crawler_monitor.controller;

import com.dayouzi.crawler_monitor.base.result.R;
import com.dayouzi.crawler_monitor.pojo.vo.LineChartData;
import com.dayouzi.crawler_monitor.pojo.vo.PanelGroupVO;
import com.dayouzi.crawler_monitor.pojo.vo.RankDataListVO;
import com.dayouzi.crawler_monitor.pojo.vo.RankDataVO;
import com.dayouzi.crawler_monitor.service.DashboardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Api(description = "首页")
@RestController
@RequestMapping("/crawler/dashboard")
@Slf4j
public class DashboardController {

    @Autowired
    private DashboardService dashboardService;

    @ApiOperation("获取首页总数量")
    @GetMapping("/getPanelGroupNum")
    public R getPanelGroupNum() {
        PanelGroupVO panelGroupVO = dashboardService.getPanelGroupNum();
        return R.ok().data("result", panelGroupVO);
    }

    @ApiOperation("获取折线图初始值")
    @GetMapping("/initLineChartData")
    public R initLineChartData() {
        LineChartData lineChartData = dashboardService.initLineChartData();
        return R.ok().data("result", lineChartData);
    }

    @ApiOperation("获取排行榜初始值")
    @GetMapping("/initRankData")
    public R initRankData(
            @ApiParam(value = "排行榜类型", required = true) String type,
            @ApiParam(value = "日期", required = true) String date
    ) {
        RankDataListVO list = dashboardService.initRankData(type, date);
        return R.ok().data("result", list);
    }

}
